import { whitePath } from '@/constants';
import { Navigate, Outlet, useModel, useSelectedRoutes } from '@umijs/max';

const Auth = () => {
  const { initialState } = useModel('@@initialState');
  //   const { isLogin } = useAuth();
  const { roleList } = initialState || {};
  const routes = useSelectedRoutes();
  const lastRoute = routes.at(-1);
  if (
    roleList?.includes(lastRoute?.route?.key) ||
    whitePath.includes(lastRoute.pathname as string)
  ) {
    return <Outlet />;
  } else {
    return <Navigate to="/403" />;
  }
};
export default Auth;
